package com.ruoyi.web.controller.basic;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.system.domain.dto.MailRequest;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.BasicSmsConfig;
import com.ruoyi.system.service.IBasicSmsConfigService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 短信配置Controller
 * 
 * @author ruoyi
 * @date 2025-03-02
 */
@RestController
@RequestMapping("/system/basicSmsConfig")
public class BasicSmsConfigController extends BaseController
{
    @Autowired
    private IBasicSmsConfigService basicSmsConfigService;


    /**
     * 查询短信配置列表
     */
    @PreAuthorize("@ss.hasPermi('system:basicSmsConfig:list')")
    @GetMapping("/list")
    public TableDataInfo list(BasicSmsConfig basicSmsConfig)
    {
        startPage();
        List<BasicSmsConfig> list = basicSmsConfigService.selectBasicSmsConfigList(basicSmsConfig);
        return getDataTable(list);
    }

    /**
     * 导出短信配置列表
     */
    @PreAuthorize("@ss.hasPermi('system:basicSmsConfig:export')")
    @Log(title = "短信配置", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, BasicSmsConfig basicSmsConfig)
    {
        List<BasicSmsConfig> list = basicSmsConfigService.selectBasicSmsConfigList(basicSmsConfig);
        ExcelUtil<BasicSmsConfig> util = new ExcelUtil<BasicSmsConfig>(BasicSmsConfig.class);
        util.exportExcel(response, list, "短信配置数据");
    }

    /**
     * 获取短信配置详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:basicSmsConfig:query')")
    @GetMapping(value = "/{smsConfigId}")
    public AjaxResult getInfo(@PathVariable("smsConfigId") Long smsConfigId)
    {
        return success(basicSmsConfigService.selectBasicSmsConfigBySmsConfigId(smsConfigId));
    }

    /**
     * 新增短信配置
     */
    @PreAuthorize("@ss.hasPermi('system:basicSmsConfig:add')")
    @Log(title = "短信配置", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BasicSmsConfig basicSmsConfig)
    {
        return toAjax(basicSmsConfigService.insertBasicSmsConfig(basicSmsConfig));
    }

    /**
     * 修改短信配置
     */
    @PreAuthorize("@ss.hasPermi('system:basicSmsConfig:edit')")
    @Log(title = "短信配置", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BasicSmsConfig basicSmsConfig)
    {
        return toAjax(basicSmsConfigService.updateBasicSmsConfig(basicSmsConfig));
    }

    /**
     * 删除短信配置
     */
    @PreAuthorize("@ss.hasPermi('system:basicSmsConfig:remove')")
    @Log(title = "短信配置", businessType = BusinessType.DELETE)
	@DeleteMapping("/{smsConfigIds}")
    public AjaxResult remove(@PathVariable Long[] smsConfigIds)
    {
        return toAjax(basicSmsConfigService.deleteBasicSmsConfigBySmsConfigIds(smsConfigIds));
    }
}
